package org.ece3574.WTParty;

import android.app.Activity;
import android.content.Intent;

public class WTParty {
	
	private WTPFacebook m_WTPFacebook;
	private Activity m_context;
	//private static final String SERVER_URL = "http://wtparty.overstrom.net/";
	private static WTParty m_thisInstance = null;
	
	public static WTParty getInstance(Activity context)
	{
		if(m_thisInstance==null)
			m_thisInstance = new WTParty(context);
		return m_thisInstance;
	}
	
	private WTParty(Activity context)
	{
		m_context = context;
		m_WTPFacebook = new WTPFacebook(m_context);
	}
	
	public String[] getFriends()	
	{
		/*
		String[] friendList;
		String strFriends = getHttp(SERVER_URL + "testfriends.txt");
		try
		{
			JSONArray jaFriendList = new JSONObject(strFriends).getJSONArray("friends");
			friendList = new String[jaFriendList.length()];
			for(int i=0;i<jaFriendList.length();i++)
			{				
				friendList[i]=jaFriendList.getJSONObject(i).getString("name");
			}
		}
		catch(Exception e)
		{
			Log.d("Error", "Error parsing friend list", e);
			return null;
		}
		Arrays.sort(friendList);
		return friendList;
		*/
		
		
		return m_WTPFacebook.getFriendList();
	}
	
	public facebookProfile getProfile()
	{
		return m_WTPFacebook.getProfile();
	}
	
	public boolean isLoggedIn()
	{
		return m_WTPFacebook.isLoggedIn();
	}
	
	public void handleFacebookCallback(int requestCode, int resultCode, Intent data)
	{
		m_WTPFacebook.handleCallback(requestCode, resultCode, data);
	}
	
	public void login(Activity a, LoginListener listener)
	{
		m_WTPFacebook.login(a, listener);
	}
	
	

}
